]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
appDisplay: Fix multi-page dragging behavior in folders
authorJonas Dreßler <verdre@v0yd.nl>
Fri, 24 Jun 2022 13:17:51 +0000 (15:17 +0200)
committerMarge Bot <marge-bot@gnome.org>
Wed, 1 Feb 2023 12:56:28 +0000 (12:56 +0000)
Folders reflow across pages because they don't set
allow_incomplete_pages to true. This means we want the nudging of items
to happen slightly differently when dragging an item across pages:

- When dragging from lower page index to a higher one, always reflow
towards the start of the grid (because there's now an empty slot on the
old page and items on the new page will force-reflow towards that)
- When dragging from a higher page index to a lower one, we can reflow to
the end as we usually do

To archive this, factor out the selection of "reflow direction" into a
separate variable that always defaults to "end" (because empty space is
always at the end of the grid). Set it to "start" when the item created an
empty slot on the current page or (and this is new:) on a previous page in
the folder case.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2348>

js/ui/appDisplay.js

index 3c7d2f3d40c1402da27f950dfeee6de606d7613b..7fbb83b32e1e7f55b11d8e6b35493805b4ad321f 100644 (file)
@@ -1177,6 +1177,16 @@ var BaseAppView = GObject.registerClass({
         const [sourcePage, sourcePosition] = this._grid.getItemPosition(source);
         let [targetPage, targetPosition, dragLocation] = this._grid.getDropTarget(x, y);
 
+        let reflowDirection = Clutter.ActorAlign.END;
+
+        if (sourcePosition === targetPosition)
+            reflowDirection = -1;
+
+        if (sourcePage === targetPage && sourcePosition < targetPosition)
+            reflowDirection = Clutter.ActorAlign.START;
+        if (!this._grid.layout_manager.allow_incomplete_pages && sourcePage < targetPage)
+            reflowDirection = Clutter.ActorAlign.START;
+
         // In case we're hovering over the edge of an item but the
         // reflow will happen in the opposite direction (the drag
         // can't "naturally push the item away"), we instead set the
@@ -1187,8 +1197,7 @@ var BaseAppView = GObject.registerClass({
         // or last column though, in that case there is no adjacent
         // icon we could push away.
         if (dragLocation === IconGrid.DragLocation.START_EDGE &&
-            targetPosition > sourcePosition &&
-            targetPage === sourcePage) {
+            reflowDirection === Clutter.ActorAlign.START) {
             const nColumns = this._grid.layout_manager.columns_per_page;
             const targetColumn = targetPosition % nColumns;
 
@@ -1197,8 +1206,7 @@ var BaseAppView = GObject.registerClass({
                 dragLocation = IconGrid.DragLocation.END_EDGE;
             }
         } else if (dragLocation === IconGrid.DragLocation.END_EDGE &&
-            (targetPosition < sourcePosition ||
-             targetPage !== sourcePage)) {
+                   reflowDirection === Clutter.ActorAlign.END) {
             const nColumns = this._grid.layout_manager.columns_per_page;
             const targetColumn = targetPosition % nColumns;